#include <stdio.h>
#include <unistd.h>

//socket编程的头文件
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int main()
{
    //创建套接字
    int sockfd = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
    if(sockfd<0)
    {
        perror("socket");
        return 0;
    }
    
    printf("socket:%d\n",sockfd);
    
    //绑定地址信息
    struct sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_port = htons(28989);
    addr.sin_addr.s_addr = inet_addr("172.16.0.5");
    int ret = bind(sockfd,(struct sockaddr*)&addr,sizeof(addr));
    if(ret < 0)
    {
        perror("bind\n");
        return 0;
    }
    while(1)
    {
        sleep(1);
    }
    return 0;
    
}
